import re
f = open('./挖宝.js',encoding='utf-8')
ret = f.read()
    #读取全部内容 ，并以列表方式返回  

#print(ret)
f.close()
f1 = open("./挖宝路径.js","r")   
lines = f1.readlines()
print(len(lines))
f1.close()
def match1():
    link="\"(.*?)/\":\" \","#这里用(.*?)而不用(.*)是为了最少的匹配，不开启贪婪模式
    print(link)
    lis=re.findall(link,ret,re.I)
    print(lis)
    print(len(lis))
    f = open("./处理后.js","w+",encoding="utf-8")
    for i in lis:
        f.write(f"'{i}':'',\n")

def match2():
    #link="go('(.*)');\n(.*)go('(.*)');\n(.*)bl_found"
    #link="\" \",(.*?)go('(.*?);')(.*?)go('(.*?);dig go')(.*?)bl_found = true;"
    link="/\":\" \",(.*?)jh (.*?)bl_found = true;"
    print(link)
    lis=re.findall(link,ret,re.S)
    f = open("./挖宝路径.js","w+",encoding="utf-8")
    for i in lis:
        print(i[1])
        f.write(f"{i[1]}\n")
def match3():
    link="\"(.*?)/\":\" \","#这里用(.*?)而不用(.*)是为了最少的匹配，不开启贪婪模式
    print(link)
    lis=re.findall(link,ret,re.I)
    print(lis)
    print(len(lis))
    f = open("./处理后.js","w+",encoding="utf-8")
    a=0
    for i in lis:
        f.write(f"'{i}':{lines[a]}\n")
        a+=1
       
    

match3()
